<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         *  1. 构造函数使用 new关键字调用
         *  2. 构造函数中的this，永远指向当前实例对象
         *  3. 构造函数不用写 return，默认返回当前实例对象[this]
         * 
         */
        function Person(name, age){
            console.log('this: ', this);// 构造函数new出来的当前实例对象
            // var obj = {};
            // obj.name = name;
            // obj.age = age;
            // return obj;
            this.name = name;
            this.age = age;
            // return this; // 可以省略
        }

        var p1 = new Person('赵四', 18);
        var p2 = new Person('王五', 29);
        console.log('p1: ', p1);
        console.log('p2: ', p2);
    </script>
</body>
</html>